package com.core.dao.mybatismysql;

import com.core.bean.Online;
import com.core.dao.IOnlineDao;
import com.core.dao.ISingleDao;
import com.core.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

public class OnlineDao implements IOnlineDao {
    public OnlineDao() {
    }

    @Override
    public Online getByUserName(String name) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        IOnlineDao iOnlineDao = session.getMapper(IOnlineDao.class);
        return iOnlineDao.getByUserName(name);
    }

    @Override
    public Online queryByToken(String token) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        ISingleDao mapper = session.getMapper(ISingleDao.class);
        return mapper.queryByToken(token);
    }

    @Override
    public int add(Online entity) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        IOnlineDao iOnlineDao = session.getMapper(IOnlineDao.class);

        return iOnlineDao.add(entity);
    }

    @Override
    public int remove(String id) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        IOnlineDao iOnlineDao = session.getMapper(IOnlineDao.class);
        return iOnlineDao.remove(id);
    }

    @Override
    public int modify(Online entity) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        IOnlineDao iOnlineDao = session.getMapper(IOnlineDao.class);
        return iOnlineDao.modify(entity);
    }

    @Override
    public Online findEntityById(String id) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        IOnlineDao iOnlineDao = session.getMapper(IOnlineDao.class);
        return iOnlineDao.findEntityById(id);
    }
}
